on:
  pull_request:
  push:
    branches:
      - main

env:
  CARGO_TERM_COLOR: always

name: Check and Lint

jobs:
  common_check:
    name: Common - Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: nightly
          override: true
      - uses: actions-rs/cargo@v1        
        with:
          command: check
          args: --manifest-path common/Cargo.toml
  shop_check:
    name: Shop - Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: nightly
          override: true
      - uses: actions-rs/cargo@v1
        with:
          command: check
          args: --manifest-path common/Cargo.toml
  common_fmt:
    name: Common - Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: nightly
          override: true
      - run: rustup component add rustfmt
      - uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --manifest-path common/Cargo.toml --all -- --check
  shop_fmt:
    name: Shop - Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: nightly
          override: true
      - run: rustup component add rustfmt
      - uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --manifest-path shop/Cargo.toml --all -- --check

  common_clippy:
    name: Common - Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          components: clippy
          override: true
      - uses: reinismu/clippy-check@master
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --all-features
          working-directory: common
          name: Common Clippy Output
  shop_clippy:
    name: Shop - Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          components: clippy
          override: true
      - uses: reinismu/clippy-check@master
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --all-features
          working-directory: shop
          name: Shop Clippy Output